package com.example.demo.web;

import com.example.demo.domain.OauthClientDetails;
import com.example.demo.service.RedisCacheUserService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController("/catch")
@Api
public class CatchTestController {
    @Autowired
    RedisCacheUserService redisCacheUserService;

    @GetMapping("/catch/{id}")
    public OauthClientDetails selectUserById(@PathVariable("id") String id) {
        return redisCacheUserService.selectUserById(id);
    }

    @GetMapping("/list/{id}")
    public List<OauthClientDetails> selectUser() {
        return redisCacheUserService.selectUser();
    }

    @GetMapping("/condition/{id}/{number}")
    public OauthClientDetails selectUserByIdWithCondition(@PathVariable("id") String id, @PathVariable("number") int number) {
        return redisCacheUserService.selectUserByIdWithCondition(id, number);
    }

    @GetMapping("/unless/{id}/{number}")
    public OauthClientDetails selectUserByIdWithUnless(@PathVariable("id") String id, @PathVariable("number") int number) {
        return redisCacheUserService.selectUserByIdWithUnless(id, number);
    }
}
